package barricades;

import java.awt.Point;



public class BottomDiagBarricade extends Barricade{

	public BottomDiagBarricade(Point mid, int length) {				
		int root=(int)Math.sqrt(length*length/2)/2;
		x_start=mid.x-root; y_start=mid.y+root; 
		x_end=mid.x+root;   y_end=mid.y-root;
	}//constructor

	public BottomDiagBarricade(Point s, Point e){
		x_start=s.x;
		x_end=e.x;
		y_start=s.y;
		y_end=e.y;
	}
	
	 public BottomDiagBarricade(Barricade b){
		 x_start=b.x_start;
		 x_end=b.x_end;
		 y_start=b.y_start;
		 y_end=b.y_end;
	}
	
	
	
	/*
	 * cuts the ends of a barricade if it is out of the simulation bounds
	 */
	public void setInBounds(int w, int h){
			
		if(x_end>w){
			
			loopHelper(w,false,true,true);	
		}
		
		if(x_start<0){
			loopHelper(0,true,true,true);	
		}
		
		if(y_end>h){
			loopHelper(h,false,true,false);	
		}else if(y_end<0){
			loopHelper(0,false,true,false);	
			
		}
		if(y_start<0){
			loopHelper(0,true,true,false);	
		}else if(y_start>h){
			loopHelper(h,true,true,false);	
		}
	}

}//class
